package com.winsomely.leecode;

/**
 * 找不同
 * 
 * @author liujiawei
 *
 */
public class FindTheDifference {

	public char findTheDifference(String s, String t) {
		if (s.length() == 0) {
			return t.charAt(0);
		}
		int[] sa = new int[26];
		int[] ta = new int[26];
		for (int i = 0; i < s.length(); i++) {
			sa[s.charAt(i) - 'a']++;
		}
		for (int i = 0; i < t.length(); i++) {
			ta[t.charAt(i) - 'a']++;
		}
		for (int i = 0; i < 26; i++) {
			if (sa[i] != ta[i]) {
				return (char) ('a' + i);
			}
		}
		return 'a';
	}

	public static void main(String[] args) {
		FindTheDifference t = new FindTheDifference();
		System.out.println(t.findTheDifference("zzzz", "zzzzz"));
	}

}
